﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ECommerce.BLL.Order;
using Jzy.Core.Utility;
using Jzy.Core.Common.Basic;
using Jzy.Core.Common.Web;
using ECommerce.Model.Order;

namespace ECommerce.Web.ECAdmin.Store
{
    public partial class List : PageList
    {
        private ECStoreBO Store
        {
            get
            {
                return ECStoreBO.Instance<ECStoreBO>();
            }
        }
       


        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                BindView();
            }
            AddAttr();
            base.InitSelectID(hidSelectIDs);
           
            lblTitle.Text = "提货地点";
            WebUtil.AllowPageScroll(this);

            JSUtil.SetTableHeight("list", 140);
        }
        private void AddAttr()
        {
            JSUtil.DelConfirm(btnDelete, "分店地址");
            JSUtil.ShowForm(lnkAdd, "增加", null, GlobalVar.WebCurrPath + "Edit.aspx", 380, 178);
            JSUtil.ClickBtn(lnkDelete, btnDelete);
        }
        private void BindView()
        {
            LVUtil.Init(lv, lvHeader);
            IEnumerable<ECStoreInfo> list = Store.GetList();
            lv.DataSource = list;
            lv.DataKeyNames = new string[] { "ID" };
            lv.DataBind();
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (strSelectIDs == "")
            {
                return;
            }
            List<int> lstSelectIDs = StrUtil.SplitToInt(strSelectIDs);
            Store.Delete(lstSelectIDs);
            BindView();
        }
        

        protected void btnRefresh_Click(object sender, EventArgs e)
        {
            BindView();
        }

        protected void lv_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                LVUtil.SetEdit(sender, e, 380, 178);
            }
        }
    }
}